VERSION 5.00
Begin VB.Form frmGetInvoiceByNumber 
   Caption         =   "שליפת חשבונית"
   ClientHeight    =   7830
   ClientLeft      =   120
   ClientTop       =   420
   ClientWidth     =   11010
   LinkTopic       =   "Form1"
   ScaleHeight     =   7830
   ScaleWidth      =   11010
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdGetAllInvoices 
      Caption         =   "הצג את כל החשבוניות"
      Height          =   375
      Left            =   4200
      TabIndex        =   6
      Top             =   960
      Width           =   2055
   End
   Begin VB.CommandButton cmdClose 
      Caption         =   "סגור"
      Height          =   375
      Left            =   120
      TabIndex        =   3
      Top             =   7320
      Width           =   855
   End
   Begin VB.TextBox txtList 
      Alignment       =   1  'Right Justify
      Height          =   5655
      Left            =   240
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   2
      Top             =   1560
      Width           =   10695
   End
   Begin VB.TextBox txtInvoiceNumber 
      Height          =   285
      Left            =   7440
      TabIndex        =   1
      Top             =   960
      Width           =   1695
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "הצג"
      Height          =   375
      Left            =   6480
      TabIndex        =   0
      Top             =   960
      Width           =   855
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      Caption         =   "טופס שליפת חשבוניות"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   177
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   6720
      TabIndex        =   5
      Top             =   360
      Width           =   4215
   End
   Begin VB.Label Label17 
      Alignment       =   1  'Right Justify
      Caption         =   "מספר החשבונית:"
      Height          =   255
      Left            =   9360
      TabIndex        =   4
      Top             =   960
      Width           =   1575
   End
End
Attribute VB_Name = "frmGetInvoiceByNumber"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const MOD_NAME = "frmGetInvoiceByID."

Private Sub cmdClose_Click()
    Unload Me
End Sub

Private Sub cmdGetAllInvoices_Click()
      Const FUNC_NAME = MOD_NAME & "cmdGetAllInvoices_Click"
10    On Error GoTo func_err
          Dim V() As Invoice
          Dim objCaspit As CaspitAPI.Caspit
          Dim I As Long
          
20        Set objCaspit = New CaspitAPI.Caspit
30        With objCaspit
40            .CaspitPath = g_strCaspitPath
50            .AccessPath = g_strAccessPath
60            .BusinessID = g_iBusinessID
70            .DebugMode = g_blnDebug
80        End With
          
90        V = objCaspit.GetInvoices
          
100       txtList.Text = ""
          
110       If IsArray(V) Then
120         If UBound(V) > 50 Then If MsgBox("נשלפו למעלה מ-50 מחשבוניות. להמשיך?", vbExclamation + vbYesNo) <> vbYes Then Exit Sub
130           For I = 0 To UBound(V)
140               PrintInvoice V(I)
150           Next
160       End If
          
170       Set objCaspit = Nothing
          
180   Exit Sub

func_err:
190        MyErrMsgBox "Error " & Err.Number & " in " & FUNC_NAME & "[" & Erl & "]" & "\" & Err.Source & ": " & Err.Description
End Sub

Private Sub cmdOK_Click()
Const FUNC_NAME = MOD_NAME & "cmdInvoice_Click"
10    On Error GoTo func_err
    Dim objCaspit As CaspitAPI.Caspit
    Dim clsInvoice As CaspitAPI.Invoice
        
20        Set objCaspit = New CaspitAPI.Caspit
30        With objCaspit
40            .CaspitPath = g_strCaspitPath
50            .AccessPath = g_strAccessPath
60            .BusinessID = g_iBusinessID
70            .DebugMode = g_blnDebug
80        End With
    
90        If Not IsNumeric(txtInvoiceNumber) Then
100     MyErrMsgBox "מספר החשבונית אינו תקין"
110     Exit Sub
120       End If
    
130       Set clsInvoice = objCaspit.GetInvoiceByNumber(CLng(txtInvoiceNumber))
140       Set objCaspit = Nothing
    
150       txtList.Text = ""
160       PrintInvoice clsInvoice
    
170       Set clsInvoice = Nothing
180   Exit Sub

func_err:
190        MyErrMsgBox "Error " & Err.Number & " in " & FUNC_NAME & "[" & Erl & "]" & "\" & Err.Source & ": " & Err.Description
End Sub

Sub PrintInvoice(clsInvoice As Invoice)
      Const FUNC_NAME = MOD_NAME & "PrintInvoice"
10    On Error GoTo func_err

          Dim clsLineItem As CaspitAPI.LineItem
          Dim I As Long
          Dim V
          
20        If clsInvoice Is Nothing Then Exit Sub
          
30        With clsInvoice
40            txtList.Text = txtList.Text & "מספר החשבונית:" & vbTab & vbTab & clsInvoice.iInvoiceNumber & vbCrLf
50            txtList.Text = txtList.Text & "סטטוס:" & vbTab & vbTab & clsInvoice.iStatusID & vbTab & DocStatus(clsInvoice.iStatusID) & vbCrLf
60            txtList.Text = txtList.Text & "תאריך:" & vbTab & vbTab & clsInvoice.datxDate & vbCrLf
70            txtList.Text = txtList.Text & "שם הלקוח:" & vbTab & vbTab & .vcBusinessName & vbTab & .iCustomersID & vbTab & .vcOsekMorshe & vbCrLf
80            txtList.Text = txtList.Text & "איש קשר:" & vbTab & vbTab & clsInvoice.vcContactDetails & vbCrLf
90            txtList.Text = txtList.Text & "כתובת1:" & vbTab & vbTab & clsInvoice.vcAddress1 & vbCrLf
100           txtList.Text = txtList.Text & "כתובת2:" & vbTab & vbTab & clsInvoice.vcAddress2 & vbCrLf
110           txtList.Text = txtList.Text & "עיר ומיקוד:" & vbTab & vbTab & clsInvoice.vcCity & vbTab & clsInvoice.vcPostalCode & vbCrLf
120           txtList.Text = txtList.Text & "פרטים:" & vbTab & vbTab & clsInvoice.vcDetails & vbCrLf
130           txtList.Text = txtList.Text & "הערות:" & vbTab & vbTab & clsInvoice.vcComments & vbCrLf
              
140           txtList.Text = txtList.Text & "שורות החשבונית:" & vbCrLf
150   On Error Resume Next
160           V = .varInvoiceLines
170         If Err.Number <> 0 And Err.Number <> -2147023113 Then Err.Raise Err.Number, "", Err.Description
180         If Err.Number = 0 Then
190   On Error GoTo func_err

200             For I = 0 To UBound(.varInvoiceLines)
210                 Set clsLineItem = .varInvoiceLines(I)
220                 txtList.Text = txtList.Text & I + 1 & vbTab & clsLineItem.ItemDescription & vbTab & _
                        clsLineItem.ItemQuantity & vbTab & clsLineItem.UnitPrice & vbTab & _
                        clsLineItem.ItemCurrency & vbTab & clsLineItem.CurrencyRate & vbTab & _
                        clsLineItem.extendedPrice & _
                        vbCrLf
230             Next
240         End If
250   On Error GoTo func_err

260           txtList.Text = txtList.Text & "סה""כ:" & vbTab & vbTab & clsInvoice.curTotal1 & vbCrLf
270           txtList.Text = txtList.Text & "הנחה:" & vbTab & vbTab & clsInvoice.curRebateAmount & vbCrLf
280           txtList.Text = txtList.Text & "הנחת עיגול:" & vbTab & vbTab & clsInvoice.curRebateRoundAmount & vbCrLf
290           txtList.Text = txtList.Text & "סה""כ לפני מע""מ:" & vbTab & vbTab & clsInvoice.curTotalBeforeVat & vbCrLf
300           txtList.Text = txtList.Text & "מע""מ:" & vbTab & vbTab & clsInvoice.curVAT & vbCrLf
310           txtList.Text = txtList.Text & "סה""כ לתשלום:" & vbTab & vbTab & clsInvoice.curGrandTotal & vbCrLf
320           txtList.Text = txtList.Text & "קבלות:" & vbTab & vbTab & clsInvoice.strReceiptNumbers & vbCrLf
330           txtList.Text = txtList.Text & "תאריך לתשלום:" & vbTab & vbTab & clsInvoice.datDueDate & vbCrLf
340           txtList.Text = txtList.Text & "---------------------------------------" & vbCrLf
              
350       End With
360   Exit Sub

func_err:
370       Err.Raise Err.Number, FUNC_NAME & "[" & Erl & "]" & "\" & Err.Source, Err.Description
End Sub



